home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / dde2 / ddepm.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1993-05-16  |  8.2 KB  |  296 lines

  1. VERSION 2.00
  2. Begin Form Form1 
  3.    Caption         =   "Create a Program Group"
  4.    ClientHeight    =   3450
  5.    ClientLeft      =   1125
  6.    ClientTop       =   2385
  7.    ClientWidth     =   8190
  8.    Height          =   4140
  9.    Icon            =   DDEPM.FRX:0000
  10.    Left            =   1065
  11.    LinkMode        =   1  'Source
  12.    LinkTopic       =   "Form1"
  13.    ScaleHeight     =   3450
  14.    ScaleWidth      =   8190
  15.    Top             =   1755
  16.    Width           =   8310
  17.    Begin DriveListBox Drive1 
  18.       Height          =   1530
  19.       Left            =   120
  20.       TabIndex        =   1
  21.       Top             =   240
  22.       Width           =   2055
  23.    End
  24.    Begin TextBox Text1 
  25.       Height          =   375
  26.       Left            =   2280
  27.       TabIndex        =   6
  28.       Text            =   "*.exe"
  29.       Top             =   240
  30.       Width           =   1215
  31.    End
  32.    Begin TextBox Text2 
  33.       Height          =   375
  34.       Left            =   6000
  35.       TabIndex        =   4
  36.       Text            =   "Examples"
  37.       Top             =   240
  38.       Width           =   2055
  39.    End
  40.    Begin DirListBox Dir1 
  41.       Height          =   2535
  42.       Left            =   120
  43.       TabIndex        =   2
  44.       Top             =   720
  45.       Width           =   2055
  46.    End
  47.    Begin FileListBox File1 
  48.       Height          =   2565
  49.       Left            =   2280
  50.       Pattern         =   "*.exe"
  51.       TabIndex        =   3
  52.       Top             =   720
  53.       Width           =   1215
  54.    End
  55.    Begin CommandButton bAdd 
  56.       Caption         =   "&Add >>"
  57.       Enabled         =   0   'False
  58.       Height          =   375
  59.       Left            =   3600
  60.       TabIndex        =   10
  61.       Top             =   720
  62.       Width           =   1215
  63.    End
  64.    Begin ListBox List1 
  65.       Height          =   2565
  66.       Left            =   4920
  67.       TabIndex        =   5
  68.       Top             =   720
  69.       Width           =   3135
  70.    End
  71.    Begin CommandButton bIterate 
  72.       Caption         =   "&Iterate >>"
  73.       Height          =   375
  74.       Left            =   3600
  75.       TabIndex        =   9
  76.       Top             =   1200
  77.       Width           =   1215
  78.    End
  79.    Begin CommandButton bRemove 
  80.       Caption         =   "<< &Remove"
  81.       Enabled         =   0   'False
  82.       Height          =   375
  83.       Left            =   3600
  84.       TabIndex        =   11
  85.       Top             =   1680
  86.       Width           =   1215
  87.    End
  88.    Begin CommandButton bMake 
  89.       Caption         =   "&Make Group"
  90.       Enabled         =   0   'False
  91.       Height          =   375
  92.       Left            =   3600
  93.       TabIndex        =   0
  94.       Top             =   2400
  95.       Width           =   1215
  96.    End
  97.    Begin CommandButton bExit 
  98.       Caption         =   "&Exit"
  99.       Height          =   375
  100.       Left            =   3600
  101.       TabIndex        =   8
  102.       Top             =   2880
  103.       Width           =   1215
  104.    End
  105.    Begin Label Label1 
  106.       Alignment       =   1  'Right Justify
  107.       Caption         =   "Group Name:"
  108.       Height          =   375
  109.       Left            =   4680
  110.       TabIndex        =   7
  111.       Top             =   240
  112.       Width           =   1215
  113.    End
  114.    Begin Menu mFile 
  115.       Caption         =   "&File"
  116.       Begin Menu mFileAll 
  117.          Caption         =   "&Add All"
  118.          Shortcut        =   ^A
  119.       End
  120.       Begin Menu mFileAbout 
  121.          Caption         =   "A&bout..."
  122.       End
  123.       Begin Menu mSep1 
  124.       End
  125.       Begin Menu mFileExit 
  126.          Caption         =   "E&xit"
  127.       End
  128.    End
  129. Option Explicit
  130. Dim Subdir(100) As String
  131. Const DEFAULT = 0        ' 0 - Default
  132. Const HOURGLASS = 11     ' 11 - Hourglass
  133. Const NONE = 0         ' 0 - None
  134. Const LINK_SOURCE = 1    ' 1 - Source (forms only)
  135. Const LINK_AUTOMATIC = 1 ' 1 - Automatic (controls only)
  136. Const LINK_MANUAL = 2    ' 2 - Manual (controls only)
  137. Const LINK_NOTIFY = 3    ' 3 - Notify (controls only)
  138. Sub bAdd_Click ()
  139.     Dim ThePath As String
  140.     Dim TheFile As String
  141.     Dim lcv As Integer
  142.     Dim AlreadyThere As Integer
  143.     If file1.FileName <> "" Then
  144.     ThePath = dir1.Path
  145.     If Right(ThePath, 1) <> "\" Then ThePath = ThePath + "\"
  146.     TheFile = ThePath + file1.FileName
  147.     For lcv = 0 To list1.ListCount - 1
  148.         If list1.List(lcv) = TheFile Then AlreadyThere = -1
  149.     Next lcv
  150.     If Not AlreadyThere Then list1.AddItem TheFile
  151.     bMake.Enabled = True
  152.     Else
  153.     bAdd.Enabled = False
  154.     End If
  155. End Sub
  156. Sub bExit_Click ()
  157.     End
  158. End Sub
  159. Sub bIterate_Click ()
  160.     Dim ThePath As String
  161.     Dim TheNextPath As String
  162.     Dim TheFile As String
  163.     Dim TheLen As Integer
  164.     Dim lcv As Integer, lcv2 As Integer
  165.     Screen.MousePointer = HOURGLASS
  166.     ThePath = dir1.Path
  167.     TheLen = Len(ThePath)
  168.     For lcv = 0 To dir1.ListCount - 1
  169.     TheNextPath = dir1.List(lcv)
  170.     If Left(TheNextPath, TheLen) = ThePath Then
  171.         file1.Path = TheNextPath
  172.         'Append a \ as needed if it's not the root
  173.         If Right$(TheNextPath, 1) <> "\" Then
  174.         TheNextPath = TheNextPath + "\"
  175.         End If
  176.         For lcv2 = 0 To file1.ListCount - 1
  177.         TheFile = TheNextPath + file1.List(lcv2)
  178.         list1.AddItem TheFile
  179.         Next lcv2
  180.     End If
  181.     Next lcv
  182.     file1.Path = dir1.Path
  183.     If list1.ListCount <> 0 Then bMake.Enabled = True
  184.     Screen.MousePointer = DEFAULT
  185. End Sub
  186. Sub bMake_Click ()
  187.     Dim rc As Integer
  188.     Dim lcv As Integer
  189.     On Error Resume Next
  190.     Screen.MousePointer = HOURGLASS
  191.     text1.LinkMode = NONE
  192.     text1.LinkTimeout = 50  '5 seconds
  193.     text1.LinkTopic = "Progman|progman"
  194.     text1.LinkMode = LINK_MANUAL
  195.     text1.LinkExecute "[CreateGroup(" + text2.Text + ")]"
  196.     rc = DoEvents()
  197.     For lcv = 0 To list1.ListCount - 1
  198.     'Debug.Print list1.list(lcv)
  199.     text1.LinkExecute "[AddItem(" + list1.List(lcv) + ")]"
  200.     rc = DoEvents()
  201.     Next lcv
  202.     text1.LinkExecute "[ShowGroup(" + text2.Text + ", 7)]"
  203.     rc = DoEvents()
  204.     text1.LinkMode = NONE
  205.     Screen.MousePointer = DEFAULT
  206. End Sub
  207. Sub bRemove_Click ()
  208.     If list1.ListIndex <> -1 Then
  209.     list1.RemoveItem list1.ListIndex
  210.     If list1.ListCount = 0 Then
  211.         bMake.Enabled = False
  212.     Else
  213.         list1.ListIndex = 0
  214.     End If
  215.     Else
  216.     bRemove.Enabled = False
  217.     End If
  218. End Sub
  219. Sub Dir1_Change ()
  220.     file1.Path = dir1.Path
  221. End Sub
  222. Sub Drive1_Change ()
  223.     Dim ans As Integer
  224.     On Error GoTo driveerror
  225.     dir1.Path = drive1.Drive
  226.     Exit Sub
  227. driveerror:
  228.     If Err = 68 Then
  229.     ans = MsgBox("Drive not ready.", 2 + 48 + 256, "Drive Error")
  230.     Select Case ans
  231.         Case 3 ' abort
  232.         drive1.Drive = Left(dir1.Path, 2)
  233.         Resume
  234.         Case 4 ' retry
  235.         Resume
  236.         Case 5 ' ignore
  237.         Resume Next
  238.     End Select
  239.     Else
  240.     On Error GoTo 0
  241.     Error Err
  242.     End If
  243. End Sub
  244. Sub File1_Click ()
  245.     If file1.FileName <> "" Then
  246.     bAdd.Enabled = True
  247.     Else
  248.     bAdd.Enabled = False
  249.     End If
  250. End Sub
  251. Sub File1_DblClick ()
  252.     bAdd_Click
  253. End Sub
  254. Sub List1_Click ()
  255.     If list1.Text <> "" Then
  256.     bRemove.Enabled = True
  257.     Else
  258.     bRemove.Enabled = False
  259.     End If
  260. End Sub
  261. Sub List1_DblClick ()
  262.     bRemove_Click
  263. End Sub
  264. Sub mFile_Click ()
  265.     If file1.ListCount > 0 Then
  266.     mFileAll.Enabled = True
  267.     Else
  268.     mFileAll.Enabled = False
  269.     End If
  270. End Sub
  271. Sub mFileAbout_Click ()
  272.     Dim TheText As String
  273.     TheText = "This program allows the selection of multiple files," + Chr(13)
  274.     TheText = TheText + "and the specification of a Group Name.  It will then " + Chr(13)
  275.     TheText = TheText + "create a Program Group in the Windows Program Manager, " + Chr(13)
  276.     TheText = TheText + "containing a Program Item for each file selected." + Chr(13) + Chr(13)
  277.     TheText = TheText + "Use the Iterate button to add all the files below the" + Chr(13)
  278.     TheText = TheText + "current sub-directory." + Chr(13) + Chr(13)
  279.     MsgBox TheText, 64, "About Make Group"
  280. End Sub
  281. Sub mFileAll_Click ()
  282.     Dim rc As Integer
  283.     Dim lcv As Integer
  284.     For lcv = 1 To file1.ListCount
  285.     file1.ListIndex = lcv - 1
  286.     bAdd_Click
  287.     rc = DoEvents()
  288.     Next lcv
  289. End Sub
  290. Sub mFileExit_Click ()
  291.     bExit_Click
  292. End Sub
  293. Sub Text1_Change ()
  294.     file1.Pattern = text1.Text
  295. End Sub
  296.